<!--{include(pe_tpl('header.html'));}-->
<div class="wgw_box">
	<div class="wgw_btn"></div>
	<div class="mat20 font16 c666">你的购物车里还没有商品</div>
	<div class="g_btn"><a href="{$pe['host']}">去逛逛</a></div>
</div>
<div class="content">
<form method="post" id="form">
<div class="dd_box">
	<!--{if(!$info['order_virtual']):}-->
	<div class="liucheng">收货地址</div>
	<div class="order_addbox" style="padding:0 0 0 45px">
		<div class="dddz_l" id="useraddr_html">
			<script type="text/html" id="useraddr_html_tpl">
			{{each list as v k}}
			<div class="addr_list js_radio {{v.sel?'sel':''}}" val="{{v.address_id}}" onclick="useraddr_select('{{v.address_id}}')">
				<i></i>{{v.address_province}} {{v.address_city}} {{v.address_area}} {{v.address_text}} （{{v.user_tname}} 收） <span class="c999">{{v.user_phone}}</span>
			</div>
			{{/each}}
			</script>
		</div>
		<div class="xzdz_btn"><a href="{$pe['host']}index.php?mod=useraddr&act=add" onclick="return pe_dialog(this, '新增地址', 630, 380)">+ 新增收货地址</a></div>
		<div class="clear"></div>
	</div>
	<div class="xuxian mat20"></div>
	<!--{endif;}-->
	<div class="liucheng">支付方式</div>
	<ul class="fkfs">
	<!--{foreach($payment_list as $k=>$v):}-->

		<label for="order_payment_{$k}" style="font-weight:normal">
			<input type="radio" name="order_payment" value="{$k}" id="order_payment_{$k}" class="mar10" />{$v['payment_name']}
			<div class="clear"></div><i></i>
		</label>
	</li>
	<!--{endforeach;}-->
	</ul>
	<div class="clear"></div>
	<div class="liucheng">商品清单</div>
	<div style="margin:20px 45px 0 45px;">
		<div class="gouwuche">
			<table width="100%" border="0" cellspacing="0" cellpadding="0">
			<tr>
				<th width="100">商品图片</th>
				<th>商品信息</th>
				<th width="80">单价</th>
				<th width="120">数量</th>
				<th width="80">小计</th>
			</tr>
			<!--{foreach($info['list'] as $k=>$v):}-->
			<tr class="js_cart" id="{$k}">
				<td class="hotimg"><img src="{$v['product_logo']}" /></td>
				<td style="text-align:left;padding-left:0">
					<a href="{pe_url('product/'.$v['product_id'])}" target="_blank">{$v['product_name']}</a>
					<div class="mat10 c999">{$v['product_rule']}</div>
				</td>
				<td class="num">¥ {$v['product_money']}</td>
				<td>{$v['product_num']}</td>
				<td>
					<!--{if($v['error']):}-->
					<span class="cred">{$v['error']['show']}</span>
					<!--{else:}-->
					<span>¥ {$v['product_allmoney']}</span>
					<!--{endif;}-->
				</td>
			</tr>
			<!--{endforeach;}-->
			</table>
		</div>
		<div class="fukuan">
			<div class="fl" style="padding:5px 10px; width:600px;">
				<div class="">
					订单留言：<input type="text" name="order_text" placeholder="请填写您的其他要求" class="ds_input" style="width:320px" />
				</div>
				<div class="mat20">
					<span class="fl mat2">店铺优惠：</span>
					<div class="fl">
						<select name="order_quan_id" class="yhq_select">
						<!--{foreach($info['quan_list'] as $k=>$v):}-->
						<option value="{$v['quanlog_id']}" quan_money="{$v['quan_money']}">{$v['quan_show']}</option>
						<!--{endforeach;}-->		
						</select>
					</div>
					<!--<a href="javascript:quan_duihuan_open();" class="mal10 cblue" style="text-decoration:underline">我要兑换</a>-->
					<div class="clear"></div>
				</div>
				<div class="mat15">
					<span class="fl">使用积分：</span>
					<label class="fl">
						<input type="checkbox" name="order_point_use" value="1" class="inputfix" />
						可用 <span id="order_point_use">0</span> 积分抵扣 <span id="order_point_money1">0</span> 元
					</label>
					<div class="clear"></div>
				</div>
			</div>
			<div class="fk_tb">
				<table width="100%" border="0" cellspacing="0" cellpadding="0">
				<tr>
					<td>商品金额：</td>
					<td width="80" class="num font14 cfen">¥ <span id="order_product_money">{$info['order_product_money']}</span></td>
				</tr>
				<tr>
					<td>运费：</td>
					<td class="num font14">¥ <span id="order_wl_money">0.0</span></td>
				</tr>
				<tr>
					<td>店铺优惠：</td>
					<td class="num font14">- ¥ <span id="order_quan_money">0.0</span></td>
				</tr>
				<tr>
					<td>积分抵扣：</td>
					<td class="num font14">- ¥ <span id="order_point_money">0.0</span></td>
				</tr>
				<tr>
					<td>应付金额：</td>
					<td class="num font18 cfen strong">¥ <span id="order_money">{$info['order_money']}</span></td>
				</tr>
				</table>
			</div>
			<div class="clear"></div>
		</div>
		<div class="cart_bot" style="background:none;">
			<input type="hidden" name="address_id" />
			<input type="hidden" name="pesubmit" />
			<input type="button" class="ddtj_btn ddtj_btn1" id="order_btn" value="提交订单" />
			<a href="{pe_url('cart')}" class="fhgw fr">< 返回购物车</a>
		</div>
	</div>
</div>
</form>
</div>
<script type="text/javascript">
$(function(){
	cart_check();
	useraddr_select(0);
	//支付方式
	pe_select_radio('order_payment', $(":input[name='order_payment']:eq(0)").val());
	//选择优惠券
	$(":input[name='order_quan_id']").live("change", function(){
		$("#order_quan_money").html($(this).find("option:selected").attr("quan_money"));
		order_money();
	})
	if ($(":input[name='order_quan_id'] option").length > 1) {
		$(":input[name='order_quan_id'] option:eq(1)").attr("selected", "selected");
		$(":input[name='order_quan_id']").change();
	}
	//使用积分
	$(":input[name='order_point_use']").change(function(){
		order_money();
	})
	$("#order_btn").click(function(){
		pe_submit("{pe_nowurl()}", function(json){
			if (json.code == 1) {
				pe_open("{$pe['host']}index.php?mod=pay&id="+json.data.id, 1000);
			}
		})
	})
})
//购物车初始化
function cart_check() {
	if ($(".js_cart").length == 0) {
		$(".wgw_box").show();
		$(".content").hide();
	}
	else {
		$(".wgw_box").hide();
		$(".content").show();	
	}
}
//获取并选择收货地址
function useraddr_select(id) {
	pe_get("{$pe['host']}index.php?mod=useraddr&cart_id={$_g_id}&id="+id, function(json){
		if (json.code == 1) {
			pe_jshtml('useraddr_html', json.data);
			$(":input[name='address_id']").val(json.data.address_id);
			$("#order_wl_money").html(json.data.wlmoney);		
		}
		order_money();
	});
}
//订单金额
function order_money() {
	var product_money = pe_num($("#order_product_money").html(), 'round', 1);
	var wl_money = pe_num($("#order_wl_money").html(), 'round', 1);
	var quan_money = pe_num($("#order_quan_money").html(), 'round', 1);
	//计算积分抵扣
	var user_point = {$info['user_point']};
	var point_bili = {$info['point_bili']};
	var point_maxlimit = {$info['point_maxlimit']};
	if (user_point > 0 && point_bili > 0 &&  point_maxlimit > 0) {
		var point_use = pe_num((product_money - quan_money) * point_maxlimit * point_bili, 'floor');
		if (point_use > user_point) point_use = user_point;
		var point_money = pe_num(point_use / point_bili, 'round', 1);
	}
	else {
		var point_use = 0;
		var point_money = 0;
	}
	$("#order_point_use").html(point_use);
	$("#order_point_money,#order_point_money1").html(point_money);
	if (!$(":input[name='order_point_use']").is(":checked")) {
		point_money = 0;
		$("#order_point_money").html(point_money);
	}
	var order_money = product_money + wl_money - quan_money - point_money;
	order_money = pe_num(order_money >= 0 ? order_money : 0, 'round', 1, true);
	$("#order_money").html(order_money);
}
</script>
<!--{include(pe_tpl('footer.html'));}-->